package com.ruoyi.web.controller.module.employee;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.employee.service.IEmployeeInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 店员 登录验证
 * 
 * @author ruoyi
 */
@RestController
@RequestMapping("/employee/info")
public class EmployeeInfoController
{
    @Autowired
    private IEmployeeInfoService employeeInfoService;

    /**
     * 登录方法
     * 
     * @param loginBody 登录信息
     * @return 结果
     */
    @PostMapping("/employeeLogin")
    public AjaxResult employeeLogin(@RequestBody LoginBody loginBody){
        return employeeInfoService.loginByPassword(loginBody.getUsername(), loginBody.getPassword());
    }

    /**
     * 退出登录方法
     *
     * @return 结果
     */
    @PostMapping("/employeeLoginOut")
    public AjaxResult loginOut(HttpServletRequest request)
    {
        return employeeInfoService.logout(request);
    }

    /**
     * 获取用户信息
     *
     * @return 用户信息
     */
    @GetMapping("/employeeInfo")
    public AjaxResult getEmployeeInfo(HttpServletRequest request)
    {
        return employeeInfoService.getLoginUser(request);
    }

}
